<template>
	<view :style="theme">
		<view class="item" v-for="(item, index) in list" :key="index">
			<view class="item_box">
				<image :src="imgHost+'/buy_ic_ticket.png'"></image>
				<view class="item_content">
					<text>{{item.businessName}}</text>
					<text>{{item.title}}</text>
					<text>{{item.createTime}}</text>
				</view>
			</view>
			<view class="item_price">{{item.type == 0 ? '+' : '-'}}{{item.money}}</view>
		</view>
		<u-loadmore v-if="end && list.length >= 15" :status="status" line />
		<view v-if="list.length === 0" class="no-order">
			<image :src="imgHost+'/default_nodata.png'"></image>
			<view>暂无通知～</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				list: [],
				page: 1,
				end: false,
				status: 'nomore',
				firstQueryTime: ''
			}
		},
		onLoad(ops) {
			this.firstQueryTime = this.$app.firstQueryTime()
			this.getList()
		},
		methods: {
			jump(url, params, a) {
				this.$app.jump(url, params, a);
			},
			jump2(url, params, a) {
				this.$app.jump2(url, params, a);
			},
			getList() {
				this.$app.ajax({
					api: this.$api.recordsOfConsumption(),
					data: {
						param: {},
						userId: this.userInfo.id,
						pagination: {
							page: this.page,
							firstQueryTime: this.firstQueryTime,
							rows: 15
						}
					}
				}).then((res) => {
					if (res.errorCode === '000000') {
						if (!res.recordList || res.recordList.length < 15) {
							this.end = true
						}
						if (res.recordList) {
							this.list = this.list.concat(res.recordList)
						}
					}
				}).catch(() => {})
			},
			reachBottom() {
				if (!this.end) {
					this.page += 1;
					this.getList();
				}
			},
			// 触底加载更多数据
			onReachBottom(e) {
				this.reachBottom()
			}
		}
	}
</script>
<style>
	page {
		background: #ffffff;
		padding: 30rpx;
		box-sizing: border-box;
	}
</style>
<style scoped lang="scss">
	.item {
		display: flex;
		justify-content: space-between;
		padding: 30rpx 0;
		box-sizing: border-box;
		border-bottom: 1rpx solid #E5E5E5;
	}

	.item_box {
		flex: 1;
		display: flex;
		align-items: flex-start;
	}

	.item_box image {
		width: 96rpx;
		height: 96rpx;
		flex-shrink: 0;
	}

	.item_content {
		display: flex;
		flex-direction: column;
		margin-left: 30rpx;
	}

	.item_content text:nth-child(1) {
		font-size: 30rpx;
		font-weight: 400;
		color: #222222;
	}

	.item_content text:nth-child(2) {
		font-size: 24rpx;
		font-weight: 400;
		color: #666666;
		margin: 10rpx 0;
	}

	.item_content text:nth-child(3) {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
	}

	.item_price {
		display: flex;
		align-items: flex-start;
		font-size: 30rpx;
		font-weight: 600;
		color: #333333;
		height: 100%;
		margin-right: 15rpx;
		margin-top: 15rpx;
	}
</style>
